package app.web.admin.domain.pojo;

import app.core.ar.ArTree;
import com.gitee.feizns.quickstart.ddl.annotation.Comment;
import com.gitee.feizns.quickstart.domain.Types;
import com.mybatisflex.core.handler.JacksonTypeHandler;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 权限菜单
 * @author feizns
 * @since 2025/3/11
 */
@Data
@Entity
@Comment("权限菜单")
@EqualsAndHashCode(callSuper = true)
@Table(name = "admin_menu")
@com.mybatisflex.annotation.Table(value = "admin_menu", comment = "权限菜单")
public class AdminMenu extends ArTree<AdminMenu> {

    /**
     * 超管理角色许可编号
     */
    public static final Long SuperAdminRolePermissionId = 1L;

    /**
     * 名称
     */
    @Comment("名称")
    private String name;

    /**
     * 唯一标识符（用冒号分隔，*代表同级所有）如：*、app:*、app:user:*
     * app:* 能匹配 app:add 及 app:add:tmp
     * *匹配所有包含 app:* 及 app:user:*
     */
    @Comment("唯一标识符（用冒号分隔，*代表同级所有）如：*、app:*、app:user:*")
    @Column(unique = true)
    private String identifier;

    /**
     * 排序字段
     */
    @Comment("排序字段")
    @Column(columnDefinition = "INT DEFAULT 0")
    private Integer sort;

    /**
     * 额外信息
     */
    @Comment("额外信息")
    @Type(type = Types.JSON)
    @Column(columnDefinition = Types.JSON)
    @com.mybatisflex.annotation.Column(typeHandler = JacksonTypeHandler.class)
    private Map<String, Object> extra = new LinkedHashMap<>();

}
